home *** CD-ROM | disk | FTP | other *** search
/ Freelog 121 / FreelogMagazineJuilletAout2014-No121.iso / Outils / Adobe-Air / adobe-air_13.exe / [0] / setup.swf / scripts / mx / binding / BindabilityInfo.as next >
Text File  |  2014-03-27  |  4KB  |  128 lines

  1. package mx.binding
  2. {
  3.    import mx.core.mx_internal;
  4.    import mx.events.PropertyChangeEvent;
  5.    
  6.    use namespace mx_internal;
  7.    
  8.    public class BindabilityInfo
  9.    {
  10.       
  11.       public static const METHOD:String = "method";
  12.       
  13.       public static const ACCESSOR:String = "accessor";
  14.       
  15.       public static const CHANGE_EVENT:String = "ChangeEvent";
  16.       
  17.       public static const NON_COMMITTING_CHANGE_EVENT:String = "NonCommittingChangeEvent";
  18.       
  19.       public static const BINDABLE:String = "Bindable";
  20.       
  21.       mx_internal static const VERSION:String = "3.0.0.0";
  22.       
  23.       public static const MANAGED:String = "Managed";
  24.        
  25.       
  26.       private var classChangeEvents:Object;
  27.       
  28.       private var typeDescription:XML;
  29.       
  30.       private var childChangeEvents:Object;
  31.       
  32.       public function BindabilityInfo(param1:XML)
  33.       {
  34.          childChangeEvents = {};
  35.          super();
  36.          this.typeDescription = param1;
  37.       }
  38.       
  39.       private function addChangeEvents(param1:XMLList, param2:Object, param3:Boolean) : void
  40.       {
  41.          var _loc4_:XML = null;
  42.          var _loc5_:XMLList = null;
  43.          var _loc6_:String = null;
  44.          for each(_loc4_ in param1)
  45.          {
  46.             if((_loc5_ = _loc4_.arg).length() > 0)
  47.             {
  48.                _loc6_ = _loc5_[0].@value;
  49.                param2[_loc6_] = param3;
  50.             }
  51.             else
  52.             {
  53.                trace("warning: unconverted Bindable metadata in class \'" + typeDescription.@name + "\'");
  54.             }
  55.          }
  56.       }
  57.       
  58.       private function getClassChangeEvents() : Object
  59.       {
  60.          if(!classChangeEvents)
  61.          {
  62.             classChangeEvents = {};
  63.             addBindabilityEvents(typeDescription.metadata,classChangeEvents);
  64.             if(typeDescription.metadata.(@name == MANAGED).length() > 0)
  65.             {
  66.                classChangeEvents[PropertyChangeEvent.PROPERTY_CHANGE] = true;
  67.             }
  68.          }
  69.          return classChangeEvents;
  70.       }
  71.       
  72.       private function addBindabilityEvents(param1:XMLList, param2:Object) : void
  73.       {
  74.          var metadata:XMLList = param1;
  75.          var eventListObj:Object = param2;
  76.          addChangeEvents(metadata.(@name == BINDABLE),eventListObj,true);
  77.          addChangeEvents(metadata.(@name == CHANGE_EVENT),eventListObj,true);
  78.          addChangeEvents(metadata.(@name == NON_COMMITTING_CHANGE_EVENT),eventListObj,false);
  79.       }
  80.       
  81.       private function copyProps(param1:Object, param2:Object) : Object
  82.       {
  83.          var _loc3_:* = null;
  84.          for(_loc3_ in param1)
  85.          {
  86.             param2[_loc3_] = param1[_loc3_];
  87.          }
  88.          return param2;
  89.       }
  90.       
  91.       public function getChangeEvents(param1:String) : Object
  92.       {
  93.          var childDesc:XMLList = null;
  94.          var numChildren:int = 0;
  95.          var childName:String = param1;
  96.          var changeEvents:Object = childChangeEvents[childName];
  97.          if(!changeEvents)
  98.          {
  99.             changeEvents = copyProps(getClassChangeEvents(),{});
  100.             var _loc4_:int = 0;
  101.             var _loc5_:* = ┬º┬ºcheckfilter(typeDescription.method);
  102.             var _loc3_:* = new XMLList("");
  103.             ┬º┬ºpush(typeDescription.accessor.(@name == childName));
  104.             typeDescription.method.(@name == childName);
  105.             ┬º┬ºpop().┬º┬ºslot[3] = ┬º┬ºnewactivation() + _loc3_;
  106.             numChildren = childDesc.length();
  107.             if(numChildren == 0)
  108.             {
  109.                if(!typeDescription.@dynamic)
  110.                {
  111.                   trace("warning: no describeType entry for \'" + childName + "\' on non-dynamic type \'" + typeDescription.@name + "\'");
  112.                }
  113.             }
  114.             else
  115.             {
  116.                if(numChildren > 1)
  117.                {
  118.                   trace("warning: multiple describeType entries for \'" + childName + "\' on type \'" + typeDescription.@name + "\':\n" + childDesc);
  119.                }
  120.                addBindabilityEvents(childDesc.metadata,changeEvents);
  121.             }
  122.             childChangeEvents[childName] = changeEvents;
  123.          }
  124.          return changeEvents;
  125.       }
  126.    }
  127. }
  128.